package edu.friday.service.impl;

import edu.friday.model.SysMenu;
import edu.friday.model.User;
import edu.friday.model.vo.SysMenuVO;
import edu.friday.model.vo.SysUserVo;
import edu.friday.repository.SysUserRepository;
import edu.friday.repository.UserRepository;
import edu.friday.service.Userservice;
import edu.friday.utils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements Userservice {

    @Autowired
    UserRepository userRepository;

    @Override
    public List<User> selectUserList(User user, Long userId) {
        List<User> UserList = null;
        User user1 = new User();
        BeanUtils.copyProperties(user, user1);
        Example example = Example.of(user1);
        if (userId == null) {
            UserList = userRepository.findAll(example);
        }
        else {
            UserList = userRepository.findAllById(userId);
        }

        return UserList;
    }
}
